layui.use(['common','layer','table','form','upload'],function(){
	var $ = layui.$,
    	layer = layui.layer,
    	form = layui.form,
    	common = layui.common,
    	table = layui.table,
    	upload = layui.upload;
	
	$.post("/systemsetup/permissionsmanage/role/selectRole",{},function(result){
		for (var i = 0; i < result.data.length; i++) {
			$("#roleId").append("<option value='"+result.data[i]["roleId"]+"'>"+result.data[i]["name"]+"</option>");
		}
		form.render('select');
	});
	 //监听提交
    form.on('submit(userAdd)', function(data){
    	
    	   $.post("/systemsetup/permissionsmanage/user/addUser",data.field,function(result){
		   if (result.status == 200) {
			   parent.layer.closeAll();
		   } else {
			   layer.msg(result.msg);
		   } 
	   });
	   return false;
    });
    
    upload.render({
  	  elem: '#picture',
  	  url: '/layuiUpload', //必填项
  	  method: 'post',  //可选项。HTTP类型，默认post
  	  accept:'images',
  	  done: function(res, index, upload){
  		console.log();
  		  
  		$("#avatar").val(res.data["fullPath"]);
  		$("#pictureSrc").attr('src',res.data["fullPath"]); 
  	  }
  	});
	
       
    
	
});